﻿using SAIM.Models.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SAIM.Models.BLL
{
    public class ImmovablesBLL : IDisposable
    {
        private SAIMEntities db;
        private List<ImmovablesDAL> _value;

        /// <summary>
        /// DAL Immovables. Contains all Immovables.
        /// </summary>
        public List<ImmovablesDAL> Value 
        {
            get { return (_value = _value ?? db.Immovables.ToList()); }
            set { _value = value; }
        }

        /// <summary>
        /// Gets a specific Immovables.
        /// </summary>
        /// <param name="Id">Immovables Id.</param>
        /// <returns></returns>
        public ImmovablesDAL getImmovable(long Id)
        {
            return Value.FirstOrDefault(i => i.Id == Id);
        }

        /// <summary>
        /// It represents a User Class for BLL. Interacts with the database and DAL to get the mapped information.
        /// </summary>
        public ImmovablesBLL()
        {
            db = new SAIMEntities();
        }

        /// <summary>
        /// Dispose this user.
        /// </summary>
        public void Dispose()
        {
            db.Dispose();
        }
    }
}